<template>
  <div>
    <!-- 登录页面 -->
    <!-- 标题栏 -->
    <van-nav-bar 
      title="登录"  
      left-text="返回"
      right-text="新用户注册"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight">
    </van-nav-bar>
    <!-- 表单 -->
    <van-form @submit="onSubmit">
    <van-cell-group inset>
    <van-field
      v-model="username"
      name="用户名"
      label="用户名"
      placeholder="用户名"
      :rules="[{ required: true, message: '请填写用户名' }]"
    />
    <van-field
      v-model="password"
      type="password"
      name="密码"
      label="密码"
      placeholder="密码"
      :rules="[{ required: true, message: '请填写密码' }]"
    />
    
      
      <!-- 两端对齐 -->
    <van-row type="flex" justify="space-between">
      <van-col span="11">
        <van-checkbox v-model="checked" shape="square">记住密码</van-checkbox>
      </van-col>
      <van-col span="6" onclick="./Register.vue">忘记密码?</van-col>
    </van-row>
    
  </van-cell-group>
  <div style="margin: 16px;">
    <van-button round block color="#fa7e3e" type="info" native-type="submit"  @click="Login">
      安全登录
    </van-button>
  </div>
  </van-form>
  </div>
</template>

<script>
import NavigationBar from "@/components/NavigationBar.vue";
import Bottom from '@/components/Bottom.vue'

export default {
  components: { NavigationBar, Bottom },
   data() {
    return {
      username: '',
      password: '',
      checked: true,
    };
  },
  methods: {
    onSubmit(values) {
        console.log('submit', values);
      },
    Login(){
      let params = `uname=${this.username}&upwd=${this.password}`
      let url = 'http://127.0.0.1:8808/v1/xsps/login'
      this.axios.post(url,params)
      .then(res=>{
        if(res.data.code == 200){
          this.$toast.success(res.data.msg);
          this.$router.push({path:'/myindex'})
        }
      })
    },

    onClickLeft() {
      Toast('返回');
    },
    onClickRight() {
      Toast('新用户注册');
    },

  },
};
</script>

<style>

</style>